package com.hzhjhh.util;

import java.time.LocalDate;

import javax.swing.JComboBox;

import org.apache.commons.lang3.StringUtils;

/**
 * 下拉框内容填充工具类
 * 
 * @author Administrator
 *
 */
public class ComboBoxFillUtils {

	public static void packingYear(JComboBox<String> jComboBox) {
		LocalDate currentYear = LocalDate.now();
		int year = currentYear.getYear();
		for (int i = year - 10; i <= year; i++) {
			jComboBox.addItem(String.valueOf(i));
		}
		jComboBox.setSelectedItem(year);
	}
	public static void packageMonth(JComboBox<String> jComboBox) {
		for (int i = 1; i <= 12; i++) {
			jComboBox.addItem(StringUtils.leftPad(String.valueOf(i), 2, "0"));
		}
		jComboBox.setSelectedItem(LocalDate.now().getMonthValue());
	}
	public static void packageDate(JComboBox<String> jComboBox) {
		for (int i = 1; i <= 31; i++) {
			jComboBox.addItem(String.valueOf(i));
		}
		jComboBox.setSelectedItem(LocalDate.now().getDayOfMonth());
	}
	
}
